<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- aabccd，去掉重复的字符，使结果显示 abcd -->
    <script>
        var str = 'aabccd'
        var arr = str.split('') //字符串转成数组用split
            //去重
        var res = arr.reduce(function(pre, cur) {
            return pre.indexOf(cur) === -1 ? pre.concat(cur) : pre
        })

        console.log(res);
    </script>
</body>

</html>